package com.tyl.handler;
import java.util.Date;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
@Slf4j //配置日志
@Component //放入容器中
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("start insert fill.............");
        this.setFieldValByName("createTime",new Date(),metaObject);//创建时间
        this.setFieldValByName("updateTime",new Date(),metaObject);//更新时间
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("start update fill.............");
        this.setFieldValByName("updateTime",new Date(),metaObject);//更新时间
    }
}
